<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DisclosureLookup.aspx.cs" Inherits="COI_DisclosureLookup" %>
<%@ Register Assembly="PHSRAG.WebControls" Namespace="PHSRAG.WebControls" TagPrefix="cc2" %>
<%@ Register Assembly="PHSRAG.Insight21.InsightWebControls" Namespace="PHSRAG.Insight21.InsightWebControls" TagPrefix="cc1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>COI - Disclosure Lookup</title>
    <link href="../Insight21.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">
    <!--
    
    

     function AddItemInList(fromLeftToRight,strMoveType)
     {
        //debugger;
        if("Users" == strMoveType)//Moving Users
        {
            var list1  = document.getElementById('<%= lstUsersFound.ClientID %>');
            var list2  = document.getElementById('<%= lstUsersForSearch.ClientID %>');
        }
        else
        {
            var list1  = document.getElementById('<%= lstOrganizationsFound.ClientID %>');
            var list2  = document.getElementById('<%= lstOrganizationsForSearch.ClientID %>');
        }
        
        if(Boolean(fromLeftToRight) == true)
        {
            return MoveItems(list1,list2);
        }
        else
        {
            return MoveItems(list2,list1);
        } 
     }
     
    function MoveItems(listFrom, listTo)
    {   
    //debugger;
        if(listFrom.options.length > 0)
        {
            for (i=0; i<listFrom.length; i++)
            {
                if (listFrom.options[i].selected)
                {
                   return true;
                }
            }
        }
        else
        {
            alert('Unable to Move Items. List is Empty!');
            return false;
        }
        return false;
    }
    
    function validateInternalSearch(strMoveType,blnAlert)
    {
        if("Users" == strMoveType)
        {
            var txtUserFistName = document.getElementById("<%=FirstName.ClientID %>");
            var txtUserLastName = document.getElementById("<%=LastName.ClientID %>");
            var txtUserName = document.getElementById("<%=UserName.ClientID %>");
            var txtSupervisorLastName = document.getElementById("<%=SupervisorLastName.ClientID %>");
            var txtSupervisorFistName = document.getElementById("<%=SupervisorFirstName.ClientID %>");
            
            if(
                ("" == trim(txtUserFistName.value)) &&
                ("" == trim(txtUserLastName.value)) &&
                ("" == trim(txtUserName.value)) &&
                ("" == trim(txtSupervisorFistName.value)) &&
                ("" == trim(txtSupervisorLastName.value))
              )
            {
                if(blnAlert)
                    alert("Enter search criteria and find Users.")
                return false;
            }
            else
            {
                return true;
            }
        }
        else
        {
            var txtOrangizationName = document.getElementById("<%=txtOrganization.ClientID%>");     
            if("" == trim(txtOrangizationName.value))
            {
                if(blnAlert)
                    alert("Enter org name and find Organizations.")
                return false;
            }
            else
            {
                return true;
            }
        }
    }
    
    function validateSearch()
    {
        if(!validateInternalSearch("Users") && !validateInternalSearch("Organizations"))
        {
            //return confirm("If you want COI of all the users with all Organizations, click OK. \n Click Cancel and select the users and/or Organizations.");
            return confirm("Displays COI of all the users with all Organizations. Do you want to continue?.");
            
        }
    }
    
    // Removes leading whitespaces
    function LTrim( value ) {
    	
	    var re = /\s*((\S+\s*)*)/;
	    return value.replace(re, "$1");
    	
    }

    // Removes ending whitespaces
    function RTrim( value ) {
    	
	    var re = /((\s*\S+)*)\s*/;
	    return value.replace(re, "$1");
    	
    }

    // Removes leading and ending whitespaces
    function trim( value ) {
    	
	    return LTrim(RTrim(value));
    	
    }
    
   
    function window.confirm(str)
    {
        execScript('n = msgbox("'+str+'","4132")', "vbscript");
        return(n == 6);
    }

     -->
    </script>
</head>
<body>
    <form id="form1" runat="server" >
        <table cellpadding="0" class="Container">
			<tr>
				<td>
				    <asp:Panel ID="headerSection" runat="server">
					<table cellspacing="0" width="100%">
						<tr>
							<td>
								<cc1:Header ID="header" runat="server" OnNavigate="Header_BreadCrumb_OnNavigate" />
							</td>
						</tr>
						<tr>
							<td>
								<cc1:CoISubNavigation ID="coiSubNavigation" OnNavigate="COISubNavigation_OnNavigate" runat="server" />
							</td>
						</tr>
						<tr>
							<td>
								<cc2:BreadCrumb ID="breadCrumb" runat="server" HighlightCurrentPage="true" OnNavigate="Header_BreadCrumb_OnNavigate" />
							</td>
						</tr>
					</table>
					</asp:Panel>
					<table id="dynamicTable" cellspacing="10" class="Invisible">
						<tr>
							<td>
								<cc2:Annunciator ID="annunciator" runat="server" ContainerID="dynamicTable" />
							</td>
						</tr>
					</table>
					<table>
						<tr>
							<td>
								<cc2:PostbackGuard ID="postbackGuard" runat="server" />
							</td>
						</tr>
					</table>	
				    <table cellpadding="5" cellspacing="5" width="100%">
				        <tr>
				            <td>
				                 <table class="Search" border="1" cellspacing="5" rules="none">
				                    <tr>
				                        <td colspan="6"><b>Search by Person:</b></td>
				                    </tr>
				                    <tr>
				                        <td align="right"><asp:Label ID="lblUserLastName" runat="server" Text="Last Name:" /></td>
				                        <td><asp:TextBox ID="LastName" runat="server" CssClass="DataInput" /></td>
				                        <td align="right"><asp:Label ID="lblUserFirstName" runat="server" Text="First Name:" /></td>
				                        <td><asp:TextBox ID="FirstName" runat="server" CssClass="DataInput" /></td>
				                        <td align="right"><asp:Label ID="lblUserName" runat="server" Text="User Name:" /></td>
				                        <td><asp:TextBox ID="UserName" runat="server" CssClass="DataInput" /></td>
				                    </tr>
				                    <tr>
				                        <td align="right"><asp:Label ID="lblSupervisorLastName" runat="server" Text="Supervisor Last Name:" /></td>
				                        <td><asp:TextBox ID="SupervisorLastName" runat="server" CssClass="DataInput" /></td>
				                        <td align="right"><asp:Label ID="lblSupervisorFirstName" runat="server" Text="Supervisor First Name:" /></td>
				                        <td><asp:TextBox ID="SupervisorFirstName" runat="server" CssClass="DataInput" /></td>
				                        <td>&nbsp;</td>
				                        <td><asp:ImageButton ID="imgBtnSearchUsers" runat="server" OnCommand="ImageButton_OnCommand" CommandName="FindUsers" ImageUrl="~/Images/find_users.gif" OnClientClick="return validateInternalSearch('Users',true);" /></td>
				                    </tr>
				                    <tr>
				                        <td colspan="2">
				                            <asp:ListBox ID="lstUsersFound" runat="server" SelectionMode="multiple" Width="340px" />
				                        </td>
				                        <td valign="middle">
				                            <asp:ImageButton ID="imgBtnMoveUsersToRight" runat="server" OnCommand="ImageButton_OnCommand" CommandName="MoveUsersToRight" ImageUrl="~/Images/arrow_right.gif" OnClientClick="return AddItemInList(true,'Users');" />
				                            <br />
				                            <asp:ImageButton ID="imgBtnMoveUsersToLeft" runat="server" OnCommand="ImageButton_OnCommand" CommandName="MoveUsersToLeft" ImageUrl="~/Images/arrow_left.gif" OnClientClick="return AddItemInList(false,'Users');" />
                                        </td>
				                        <td colspan="2" >
				                            <asp:ListBox ID="lstUsersForSearch" runat="server" Width="340px" />
				                            <asp:HiddenField ID="hdnUsersForSearch" runat="server" />
				                        </td>
				                        <td>&nbsp;</td>
				                    </tr>
				                    <tr>
				                        <td colspan="6"><hr /></td>
				                    </tr>
				                    <tr>
				                        <td colspan="6"><b>Search by Organization:</b></td>
				                    </tr>
				                    <tr>
				                        <td align="right">Company / Organization:</td>
				                        <td><asp:TextBox ID="txtOrganization" runat="server"></asp:TextBox></td>
				                        <td><asp:ImageButton ID="imgBtnSearchOrganziations" runat="server" OnCommand="ImageButton_OnCommand" CommandName="FindOrganizations" ImageUrl="~/Images/find_organizations.gif" OnClientClick="return validateInternalSearch('Organizations',true);"/></td>
				                    </tr>
				                    <tr>
				                        <td colspan="2">
				                            <asp:ListBox ID="lstOrganizationsFound" runat="server" SelectionMode="multiple" Width="340px" >
				                            </asp:ListBox>
				                        </td>
				                        <td valign="middle">
				                            <asp:ImageButton ID="imgBtnOrganizationsMoveToRight" runat="server" OnCommand="ImageButton_OnCommand" CommandName="MoveOrganizationsToRight" ImageUrl="~/Images/arrow_right.gif" OnClientClick="return AddItemInList(true,'Organizations');" />
				                            <br />
				                            <asp:ImageButton ID="imgBtnOrganizationsMoveToLeft" runat="server" OnCommand="ImageButton_OnCommand" CommandName="MoveOrganizationsToLeft" ImageUrl="~/Images/arrow_left.gif" OnClientClick="return AddItemInList(false,'Organizations');" />
                                        </td>
				                        <td colspan="2" align="left">
				                            <asp:ListBox ID="lstOrganizationsForSearch" runat="server" Width="340px" />
				                            <asp:HiddenField ID="hdnOrganizationsForSearch" runat="server"  />
				                        </td>
				                        <td valign="bottom">
				                            <asp:ImageButton ID="imgBtnSearchDisclosures" runat="server" OnCommand="ImageButton_OnCommand" CommandName="SearchDisclosures" ImageUrl="~/Images/b_search.gif" OnClientClick="return validateSearch();" /> <!-- OnClientClick="return AddListItemsToHiddenControl();" />-->
				                            &nbsp;&nbsp;&nbsp;&nbsp;
				                            <asp:ImageButton ID="imgBtnClearSearchCriteria" runat="server" OnCommand="ImageButton_OnCommand" CommandName="ClearSearchCriteria" ImageUrl="~/Images/b_clearselect_grey.gif"/>
                                        </td>
				                    </tr>
				                </table>	
				            </td>
				        </tr>
				    </table>	
				    <asp:Panel ID="gridContainer" runat="server" Visible="false">
                        <br />
                        <table class="PlaceBar" width="100%">
                            <tr>
                                <td class="PageName">
                                    &nbsp;&nbsp;<asp:Label ID="recordCount" runat="server"></asp:Label>&nbsp;Records
                                </td>
                                <td align="right">
                                    <cc2:DownloadBar ID="downloadBar" runat="server" EnableExcelLink="false" EnablePDFLink="false"></cc2:DownloadBar>
                                </td>
                            </tr>
                        </table>
                        <table width="100%">
                            <tr>
                                <td>
                                    <cc2:Pager ID="topPager" runat="server" OnFirstPage="Pager_OnFirstPage" OnLastPage="Pager_OnLastPage" OnPreviousPage="Pager_OnPreviousPage" OnNextPage="Pager_OnNextPage"></cc2:Pager>
                                </td>
                            </tr>
                        </table>     
                        <table cellspacing="0" width="100%">
                            <tr>
                                <td>
                                    <asp:GridView ID="gvDisclosures" runat="server" Width="100%" CssClass="DataGrid" 
                                         AllowPaging="true" AllowSorting="true" AutoGenerateColumns="false"
                                         PagerSettings-Visible="False" OnSorting = "gvDisclosures_OnSorting" OnRowCreated="gvDisclosures_OnRowCreated">
                                        <HeaderStyle CssClass="DataGridHeader" />
                                        <FooterStyle CssClass="DataGridHeader" />
                                        <AlternatingRowStyle CssClass="DataGridAlternatingItem" />   
                                        <RowStyle CssClass="DataGridItem" />
                                        <Columns>
                                            <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                                            <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                                            <asp:BoundField DataField="OrgName" HeaderText="Organization" SortExpression="OrgName" />
                                            <asp:BoundField DataField="TypeOfInterest" HeaderText="Type Of Interest" SortExpression="TypeOfInterest" />
                                        </Columns>
                                    </asp:GridView>
                                 </td>
                            </tr>
                            <tr>
                                <td>
                                    <cc2:Pager ID="bottomPager" runat="server" OnFirstPage="Pager_OnFirstPage" OnLastPage="Pager_OnLastPage" OnPreviousPage="Pager_OnPreviousPage" OnNextPage="Pager_OnNextPage"></cc2:Pager>
                                </td>
                            </tr>
                        </table>                   
                    </asp:Panel>                   
                </td>
            </tr>
            <tr>
                <td>
                    <asp:HiddenField ID="hdnSortColumn" runat="Server" Value="LastName" />
                    <asp:HiddenField ID="hdnSortOrder" runat="server" Value="ASC" />
                </td>
            </tr>
        </table>                            				
    </form>
</body>
</html>
